# Customise this file, documentation can be found here:
# https://github.com/fastlane/fastlane/tree/master/fastlane/docs
# All available actions: https://docs.fastlane.tools/actions
# can also be listed using the `fastlane actions` command

# Change the syntax highlighting to Ruby
# All lines starting with a # are ignored when running `fastlane`

# If you want to automatically update fastlane if a new version is available:
# update_fastlane

# This is the minimum version number required.
# Update this, if you use features of a newer version
fastlane_version "2.3.0"

default_platform :ios

platform :ios do
    gym_output_path = "../Build/"

    before_all do
        cocoapods(repo_update: true)
        if is_ci
            setup_jenkins(result_bundle: false)
            gym_output_path = "../Build/#{ENV['BUILD_NUMBER']}"
        end
    end

    lane :AdHoc do
        # register_devices(devices_file: "fastlane/devices.txt")
        match(force_for_new_devices: true, type: "adhoc")
        gym(scheme: "Debug",
            configuration: "AdHoc",
            output_directory: gym_output_path)
    end

    desc "Deploy a new version to the App Store"
    lane :Release do
        match(type: "appstore")
        pem
        puts "Version: #{get_version_number}"
        increment_build_number(build_number: "#{get_version_number}.#{ENV['BUILD_NUMBER']}")
        gym(scheme: "Release",
            archive_path: gym_output_path,
            output_directory: gym_output_path)
        upload_symbols_to_crashlytics(dsym_path: "#{gym_output_path}/RetailApp.app.dSYM.zip",
                                      api_token: "04401f2c28db86cf44d0c8b1b62305c9d1893ce6",
                                      binary_path: "./Pods/Fabric/upload-symbols")
        appstore(skip_screenshots: true, force: true)
    end

    lane :Enterprise do
        ENV["MATCH_FORCE_ENTERPRISE"] = "1"
        match(type: "development",
              username: "zhaoguangjun915@gmail.com",
              git_branch: "dev",
              app_identifier: "com.2dfire.RetailAppPro")
        gym(scheme: "Enterprise",
            output_directory: gym_output_path)
        #crashlytics(ipa_path: "#{gym_output_path}/RetailApp.ipa")
    end

    after_all do |lane|
    end

    error do |lane, exception|
    end
end


# More information about multiple platforms in fastlane: https://github.com/fastlane/fastlane/blob/master/fastlane/docs/Platforms.md
# All available actions: https://docs.fastlane.tools/actions

# fastlane reports which actions are used
# No personal data is recorded. Learn more at https://github.com/fastlane/enhancer
